package com.ruoyi.h5.eval.controller;

import com.dgy.teachResource.pojo.dto.SelectTeachRecordDTO;
import com.dgy.teachResource.pojo.vo.TeachRecordVO;
import com.dgy.teachResource.service.ITeachRecordService;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.util.ObjectUtils;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

/**
 * 教学记录Controller
 *
 * @author ccc
 * @date 2025-02-12
 */
@RestController
@RequestMapping("h5/teach/record")
public class H5TeachRecordController extends BaseController
{

    @Autowired
    private ITeachRecordService teachRecordService;

    /**
     * 教学记录列表
     */
//    @PreAuthorize("@ss.hasPermi('teach:record:getList')")
    @PostMapping(value = "/getList")
    public TableDataInfo getList(@Validated @RequestBody SelectTeachRecordDTO selectTeachRecordDTO)
    {
        return teachRecordService.selectTeachRecord(selectTeachRecordDTO);
    }

    /**
     * 教学记录详情
     * @param teachRecordId
     * @return
     */
//    @PreAuthorize("@ss.hasPermi('teach:record:detail')")
    @GetMapping(value = "/detail/{teachRecordId}")
    public AjaxResult getList(@PathVariable String teachRecordId)
    {
        // 获取授课详情
        TeachRecordVO teachRecordVO = teachRecordService.getTeachRecordInfo(teachRecordId);
        if(ObjectUtils.isEmpty(teachRecordVO)){
            return error("授课记录不存在");
        }
        return success(teachRecordVO);
    }

}
